﻿package java_45;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import entity.NewTitle;

public class NewTitleDemo {

    public static void main(String[] args) {
       
        NewTitle car = new NewTitle(1, "汽车", "管理员");
        NewTitle test = new NewTitle(2, "高考", "管理员");
      
        Set newsTitleList = new HashSet();
       
        newsTitleList.add(car);
        newsTitleList.add(test);
        
        System.out.println("新闻标题数目为：" + newsTitleList.size() + "条");
      
        Iterator iterator = newsTitleList.iterator();
       
        while(iterator.hasNext()){
            NewTitle title = (NewTitle) iterator.next();
            System.out.println(title.getTitleName());
        }
        System.out.println("************************");
      
        for(Object obj:newsTitleList){
            NewTitle title = (NewTitle)obj;
            System.out.println(title.getTitleName());
        }
    }

}